<!--单项目文件--查看交付物（交付物流程）-->
<!--当前页面业务逻辑
1.从待办流程处点击进入交付物页面，属于查看交付物流程页面；从其他地方点交付物进入交付物页面都属于交付物查看页面
2.交付物流程页面，显示内容：
  a.流程节点名称获取待办流程中的“操作”字段
  b.当流程的“状况==已完成”,基本信息、交付物（添加、移除按钮隐藏）、流程处理（流程试图、流程记录、流程处理隐藏）、“起草人”按钮隐藏、“操作”按钮变成流程节点
  c.当流程的“状况!=已完成”,基本信息、交付物（流程试图有数据时 添加、移除按钮(状态为“正在工作”和“重新工作”)显示）、流程处理（流程试图、流程记录、流程处理显示、选人显示（状况==编制、修改））、“操作”按钮变成流程节点、
  “起草人”按钮显示（状况!=提交、编制、修改）
3.交付物查看页面，显示内容：操作按钮、基本信息、交付物（添加、移除按钮隐藏）、流程处理（流程试图、流程记录显示、流程处理隐藏、选人隐藏）、历史版本
4.点击待办中心的待办流程--流程名称，进入的页面跟从项目文件点进来的一样
-->
<template>
  <div class="examineProject" ref="examineProject" >
    <div class="headMain">
      <div class="headTitle">
        <a-dropdown v-if="isShowCurrent">
          <a-button class="style-button">操作
            <a-icon type="down"/>
          </a-button>
          <!--          <a-menu slot="overlay" @click="handleMenuClick" class="style-dropdown-menu">-->
          <a-menu slot="overlay" class="style-dropdown-menu">
            <!--            <a-menu-item v-for="item in selectArr" :key="item.key">{{ item.label }}</a-menu-item>-->
            <a-menu-item v-for="item in selectArr" :key="item.key">
              <a-button class="menuBtn" :disabled="item.show" @click="elSelectBtn(item.key)"> {{ item.label }}
              </a-button>
            </a-menu-item>
          </a-menu>
        </a-dropdown>
        <div class="processName" v-else>【{{ processName }}】</div>
        <div class="processName">{{ deliverableName }}
            <a-tooltip placement="topLeft" title="已被您检出">
                <img src="@/assets/single/doc.png" style="width: 16px;height: 14px;margin-left:4px;margin-top: -20px;" v-if="isCheckOut"/>
             </a-tooltip>
        </div>
      </div>
      <div class="productTitle">基本信息</div>
      <div>
        <div v-if="basicInformation.length !== 0" style="padding-bottom: 10px;">
          <div class="messageContent" v-for="(item, index) in basicInformation" :key="index">
            <div v-for="item1 in item.items" :class="item1.length==1?'message_de':'message_deOne'"
                 :key="item1.id">
              <detailMessage :attrList="item1"></detailMessage>
            </div>
          </div>
        </div>
        <a-empty v-else description="暂无数据" class="nodata"/>
      </div>
    </div>
    <div class="styleTabsMain">
      <a-affix  :target="() => $refs.examineProject">
      <ul class="styleTabs" style="line-height:46px">
        <li @click="toScroll(0, '.module0')" :class="activeTabs === 0 ? 'activeTabs' : ''">交付物</li>
        <li @click="toScroll(1, '.module1')" :class="activeTabs === 1 ? 'activeTabs' : ''">流程处理</li>
        <li v-if="isShowHistoryVerion" @click="toScroll(2, '.module2')" :class="activeTabs === 2 ? 'activeTabs' : ''">
          历史版本
        </li>
      </ul>
      </a-affix>
      <div class="components-styles-module module0" style="margin-top: 0px;min-height: 200px">
        <div class="style-pac-btn">
          <p class="title">交付物</p>
          <div class="deliBtnList" v-if="isShowDeliBtnList">
            <a-button type="primary" style="margin-right: 15px" @click="addDeliver()">添加</a-button>
            <a-button style="margin-right: 15px" @click="delDeliver">移除</a-button>
          </div>
          <!--          上传交付物modal-->
          <commElFilestartUpload ref="commElFilestartUpload" v-if="isShowUploadFile"
                                 :startSingleID='currentOid'
                                 @initTableData='initTableDataDeliver'
                                 @callbackData='callbackData'
                                 :startType='"callbackData"'
                                 @closeUpFile="closeUpFile"></commElFilestartUpload>
        </div>
        <div class="main" style="padding: 10px 20px 10px 20px">
          <!--          交付物列表-->
          <task-table ref="deliverTable" :table-data="tableDataDe" :load-visible="loadingVisible"
                      :row-selection="rowSelection" :deliver-id="deliverId" :data-row-key="deliverTableKey"
                      :is-rows-select-visible="isRowsSelectVisible"
                      @routerSubmitDel="routerSubmitDel" @selectRowsEvent="selectRowsEvent"
                      :table-columns="tableColumnsDe" :pagination="tablePagination"></task-table>
        </div>
      </div>
      <div class="components-styles-module module1" style="margin-top: 10px;">
        <div class="style-pac-btn">
          <p class="title">流程处理</p>
          <a-button type="primary" style="width: 168px;margin-right: 15px" v-if="isShowSponsor" @click="openDraw">
            以起草人身份操作
          </a-button>
        </div>
        <div class="main">
          <!--          流程选人设置-->
          <commonProcessSettings v-if="isShowProcessSetting" ref="commonProcessSettings" :form-data="formData"
                                 :Oid='currentOid' @fields='fields'></commonProcessSettings>
          <!--          流程节点(流程试图、流程操作历史记录、流程审核操作)-->
          <commonProcess ref="peocessCon" :step-arr="stepArr" :process-table-is-show="processTableIsShow"
                         :bottom-describe-is-show="isShowBottomDescribe" :table-arr="tableArr"
                         :radio-arr="radioArr" @submitProcessPeople="submitProcessPeople"></commonProcess>
        </div>
      </div>
      <div v-if="isShowHistoryVerion" class="components-styles-module module2" style="margin-top: 10px;">
        <p class="title">历史版本</p>
        <div class="main">
          <!--          历史版本-->
          <common-table
            :columns="columns"
            :tableData="historyRecord"
            :data-row-key="historyTableKey"
            @routerPage="routerPage"
            :loadVisible="loadVisible"
            @selectedRows="selectedRows"
            @routerContextmenu='routerContextmenu'/>
        </div>
      </div>
      <!--      <div class="operatingBtnList" style="margin-top: 0px;">
              <a-button @click="submitProcessPeople" type="primary"> 提交</a-button>
            </div>-->
    </div>
    <!--    操作按钮的弹框集合-->
    <commModal ref="commModal" @initTableData='initTableData' @initSigoView='initSigoView'></commModal>
    <!--    以起草人身份操作抽屉-->
    <comm-el-process-handle v-show="isShowProcessHandle" @closeDraw="closeDraw"></comm-el-process-handle>
  </div>
</template>
<script>
import {
  getAttributeGroup,
  getVersionHistory,
  getProcessSteps,
  getDisposeStatus,
  getDisplayIdentifier,
  getRouting,
  completeWorkItem,
  reassignWorkItem,
  getDocProcessReviewObjs,
  removeDocProcessReviewObj,
  getWFSelectPrincipal,
  updateTeamPrincipal,
  addDocProcessReviewObj, checkDocActionPermission
} from "@/api/fileSingle.js"
import copyACtion from '@/views/singleProject/fileSingle/el-common-js/copy'
import commonProcess from '@/components/processCommon/approveProcess'
import approveFrom from '@/components/processCommon/createProcess/approveFrom'
import commonTable from '@/components/common/commonTable'
import commModal from "@/views/singleProject/fileSingle/el-common/comm-modal";
import taskTable from "@/views/plmHomePage/toDoPage/comp/taskTable.vue";
import commElFilestartUpload from '@/views/singleProject/fileSingle/el-common/comm-el-filestart-upload'//添加交付物模态框
import commonProcessSettings from '@/components/common/commonProcessSettings'//流程处理选择人员（修改）
import commElProcessHandle from '@/views/singleProject/fileSingle/el-common/comm-el-processHandle'//以起草人身份操作
import detailMessage from "@/components/singlePage/detailMessage";
import lodash from "lodash";
import _ from "lodash";
import {mapGetters} from "vuex";
const columns = [
  {
    displayName: "版本",
    name: "version",
    scopedSlots: {customRender: "name"}
  },
  {
    displayName: "文件名",
    name: "fileName",
  },
  {
    displayName: "大小",
    name: "size",
  },
  {
    displayName: "交付状态",
    name: "state",
  },
  {
    displayName: "备注",
    name: "remarks",
  },
  {
    displayName: "修改者",
    name: 'modifier',
    scopedSlots: {
      filterDropdown: "filterDropdown",
      filterIcon: "filterIcon",
      customRender: "customRender"
    }
  },
  {
    displayName: "上次修改时间",
    name: "lastModifyTime",
    scopedSlots: {
      filterDropdown: "filterDropdown",
      filterIcon: "filterIcon",
      customRender: "customRender"
    }
  }
];
const data = [
  {
    name: 'Jim Green',
    id: 42,
    start: 'London No. 1 Lake Park',
    qteName: 465,
  },
  {
    name: 'Joe Black',
    id: 32,
    start: 'Sidney No. 1 Lake Park',
    qteName: 456,
  },
];
export default {
  mixins: [copyACtion],
  data() {
    return {
      userinfo: JSON.parse(sessionStorage.getItem('userInfo')),//用户信息
      deliverableName: '',//交付物名称
      isCheckOut: false,//是否已检出
      processName: '',//流程节点名称
      recordingKey: '',
      currentOid: '',
      isShowCurrent: false,//是否显示“操作”按钮
      isShowHistoryVerion: false,//是否显示历史版本
      isShowSponsor: false,//是否发起人（起草人）
      isShowDeliBtnList: false,//是否显示交付物添加、移除按钮
      isShowBottomDescribe: false,//流程处理是否显示
      isShowProcessSetting: false,//是否显示流程人员设置
      processTableIsShow: true,//流程记录表格是否显示
      activeTabs: 0,
      selectArr: [
        {key: 'download', label: '下载', show: false},
        {key: 'startSignWorkflow', label: '启动文档签审', show: false},
        {key: 'copy', label: '复制', show: false},
        // {key: 'commElDelete', label: '删除', show: false},
        // {key: 'commElRevise', label: '修改交付物', show: false},
        {key: 'commElRename', label: '重命名', show: false},
        {key: 'commElRevision', label: '修订交付物', show: false},
        // {key: 'cut', label: '剪切', show: false},
        // {key: 'paste', label: '粘贴', show: false},
        {key: 'commElMobile', label: '移动', show: false},
        {key: 'checkIn', label: '检入', show: false},
        {key: 'checkOut', label: '检出', show: false},
        {key: 'unCheckOut', label: '撤销检出', show: false},
        {key: 'commElStatusSetting', label: '设置状态', show: false},
        {key: 'commElControlAuthority', label: '编辑访问控制', show: false}
      ],
      basicInformation: [],
      historyRecord: [],
      columns,
      data,
      selectedRowKeys: [],
      loadVisible: false,
      isRowsSelectVisible: true,
      stepArr: [],//流程视图数据
      tableArr: [],//流程记录表格数据
      radioArr: [],//单选框数据
      tableColumnsDe: [
        {
          title: "交付物",
          dataIndex: "name",
          width: '30%',
          ellipsis: true,
          scopedSlots: {customRender: "subjectNameDelive"}
        },
        {
          title: "提交人",
          dataIndex: "creator",
          width: '25%',
          ellipsis: false,
        },
        {
          title: "提交时间",
          width: '25%',
          dataIndex: "modifyDate"
        },
        {
          title: "交付物状态",
          width: '20%',
          dataIndex: "state"
        },
        {
          title: "是否最新版本",
          width: '20%',
          dataIndex: "isLatestVersion"
        }
      ],//交付物表头
      tableDataDe: [],//交付物列表
      loadingVisible: false,
      rowSelection: false,//交付物是否显示多选
      // tablePagination: {
      //   pageSize: 0,
      // },//交付物分页
      tablePagination:false,  //不显示分页
      selectRowsDeliver: [],//选中的数据--交付物
      isShowProcessHandle: false,//显示以起草人身份操作抽屉
      deliverId: '',//交付物主id
      historyTableKey: '',//历史记录表格的key
      deliverTableKey: '',//交付物表格的key
      formData: [],//流程选人设置
      isShowUploadFile: false,//是否显示上传交付物
      radioVal: '',//操作的选择
      desVal: '',//操作意见
      reassignUser: '',//转办人
      titleArr2: [
        {id: 'download', number: 10},
        {id: 'startSignWorkflow', number: ''},
        {id: 'copy', number: ''},
        // {id: 'commElDelete', number: 5},
        {id: 'commElRevise', number: 1},
        {id: 'commElRename', number: 16},
        {id: 'commElRevision', number: 7},
        // {id: 'cut', number: 12},
        // {id: 'paste', number: 2},
        {id: 'commElMobile', number: 12},
        {id: 'checkIn', number: ''},
        {id: 'checkOut', number: ''},
        {id: 'unCheckOut', number: ''},
        {id: 'commElStatusSetting', number: 15},
        {id: 'commElControlAuthority', number: 9}
      ],//操作按钮
      fromPath: '',//上一个页面的路由
      fileSingleItem: JSON.parse(sessionStorage.getItem('fileSingleTableItem')),//存入vuex的文件(交付物)数据
      fileSingleDataItem: JSON.parse(sessionStorage.getItem('fileSingle')),
      fileSingleDataC: {},//xxxx
      sessionData: [],//从不同页面进入此页面保存的session
      historyVersionOid:'',//历史版本的Oid
    }
  },
  components: {
    commModal,
    commonProcess,
    approveFrom,
    commonTable,
    taskTable,
    commElFilestartUpload,
    commonProcessSettings,
    commElProcessHandle,
    detailMessage
  },
  created() {
  },
  beforeRouteEnter(to, from, next) {
    next(vm => {
      vm.fromPath = from.path
    })
  },
  computed: {
    ...mapGetters({
      // 'fileSingleData': 'fileSingle'
    })
  },
  watch:{
    fileSingleItem(newVal,oldVal){
       this.fileSingleItem = newVal
        this.currentOid = newVal.oid
        this.sessionData = [newVal]
    }
  },
  mounted() {
    if (this.fromPath.indexOf('fileSingle') > -1 && this.$route.query.to == 'sigleFile') {//从项目文件跳转
      this.currentOid = this.fileSingleDataItem.tableArr[0].oid
      this.sessionData = this.fileSingleDataItem.tableArr
     // console.log('从项目文件跳转进来时传的Oid',this.currentOid,'和sessionData:',this.sessionData);
    } else {//从待办中心待办流程跳转或者其他页面跳转
      // this.currentOid = this.fileSingleItem.oid     //之前的
      // this.sessionData = [this.fileSingleItem]
      this.currentOid = JSON.parse(sessionStorage.getItem('fileSingleTableItem')).oid || JSON.parse(sessionStorage.getItem('fileSingleTableItem'))[0].oid
      this.sessionData = JSON.parse(sessionStorage.getItem('fileSingleTableItem'))
      //console.log('从非项目文件页面跳转进来的Oid:', this.currentOid,'和sessionData:',this.sessionData)
    }
    console.log(this.sessionData);
    // this.currentOid = this.fileSingleItem.oid//当前页面调取接口所需的oid（流程id/交付物id）
    this.deliverId = this.fileSingleItem.oid//交付物列表中主交付物id
    /*isShowCurrent: true,//是否显示“操作”按钮
      isShowHistoryVerion:true,//是否显示历史版本
      isShowSponsor: false,//是否发起人（起草人）
      isShowDeliBtnList:false,//是否显示交付物添加、移除按钮
      isShowBottomDescribe: true,//流程处理是否显示*/
    if (this.currentOid.indexOf('WorkItem') > -1) {//处于流程中
      this.getRoutingIndex()//获取操作流程
      if (this.fileSingleItem.workItemState === '已完成') {//流程状况已完成
        this.isShowBottomDescribe = false
      } else {
        this.isShowBottomDescribe = true
      }
      this.isShowHistoryVerion = false
      this.isShowCurrent = false
      //当流程名称为“修改/编制”时，显示流程人员设置
      this.processName = this.fileSingleItem.workItemName
      if ((this.processName == '修改' || this.processName == '编制') && this.fileSingleItem.workItemState !== '已完成') {
        this.isShowProcessSetting = true
        this.getProcess()//获取流程人
      } else {
        this.isShowProcessSetting = false
      }
    } else {
      this.isShowHistoryVerion = true
      this.isShowBottomDescribe = false
      this.isShowCurrent = true
      this.getActionPermission(this.currentOid)//非“操作”执行
    }
    this.initData()
  },
  methods: {
     /**
     * common-table 组件回调    点击查看历史版本
     */
    routerPage(val) {
    //  console.log('------点击查看历史',val)
      this.currentOid = val.oid;
      this.initData();
      let el = document.querySelector('.ant-layout-header');
      el.scrollIntoView();
    },
    /**
     * 更多操作按钮事件
     * 功能：判断当前点击的操作，开启对应弹窗
     *      val：点击是对应的对象
     */
    /*handleMenuClick(val) {
      this.recordingKey = val.key
      if(this.currentOid.indexOf('WorkItem') > -1){
      }
      this.$refs.commModal.openElModal(val.key, this.fileSingleItem, [this.fileSingleItem.tableItem], true)
      // this.$refs.commModal.openElModal(key)
    },*/
    /**
     * 更多 Select 操作
     * key: click事件传的key
     **/
    elSelectBtn(key) {
      this.recordingKey = key
      if (key === 'startSignWorkflow') return this.startDocument()
      this.$refs.commModal.openElModal(key, this.sessionData)
      // this.$refs.commModal.openElModal(key, this.fileSingleItem, [this.fileSingleItem.tableItem], true)
    },
    /**
     * 控制按钮权限
     **/
    getActionPermission(oid) {
      checkDocActionPermission({oid: oid, actions: this.titleArr2}).then((res) => {
        if (res && res.data.success) {
          res.data.data[9].show = res.data.data[7].show   //检入的按钮权限 赋给 撤销检出
          let arr = res.data.data
          arr.forEach(item => {
            this.selectArr.forEach(el => {
              if (item.id === el.key) {
                el.show = !item.show
              }
            })
          })
          this.selectArr[2].show = false
          // this.selectArr[7].show = 'disabled'
          // this.selectArr[8].show = 'disabled'
        } else {
          this.$message.error(res.data.message)
        }
      })
    },
    /**
     * 启动文档
     */
    startDocument() {
      /*if (this.tableSelectArr.length < 1) return this.$message.error('请选择您所需要启动签审的文档')
      this.fileSingleDataItem.tableArr = this.tableSelectArr
      this.setFileSingle(this.fileSingleDataItem)*/
      let sessArr = {
        tableArr: this.sessionData
      }
      sessionStorage.setItem('fileSingleDataByStart', JSON.stringify(sessArr))
      this.$router.push('fileStart');
    },
    /**
     * tab 点击事件
     * 功能：点击对应的tab跳转到对应的位置
     */
    toScroll(num, key) {
      this.activeTabs = num
      let el = document.querySelector(key)
      el.scrollIntoView()
    },
    /**
     * common-table 组件选择行回调
     */
    selectedRows() {
      console.log('------selectedRows')
    },
    /**
     * common-table 组件点击行回调
     */
    routerContextmenu() {
      console.log('------routerContextmenu')
    },
    /**
     * comm-modal 组件回调
     * 功能：通知更新数据
     */
    initTableData() {
      let sessionOid = JSON.parse(sessionStorage.getItem('fileSingleTableItem')); 
      let newOid = sessionOid.oid==undefined?'':sessionOid.oid;
      this.currentOid = newOid||this.currentOid;
      this.initData()
      this.getActionPermission(this.currentOid)//非“操作”执行
    },
    /**
     * 数据初始化
     * getAttributeGroup ： 获取基本信息
     * getVersionHistory： 获取历史记录
     */
    initData() {
      //交付物名称
      console.log('初始化数据')
      getDisplayIdentifier({oid:this.currentOid}).then((res) => {
        if (res && res.data && res.status === 200) {
          if (res.data.success) {
            // 去掉标题的状态字符 入 A.1-审核，去掉 -审核
            let str = res.data.message.slice(res.data.message.length-3,-2)
            if(str=='-'){
              this.deliverableName = res.data.message.substring(-1,res.data.message.length-3)
            }else{
               this.deliverableName = res.data.message
               if(this.deliverableName.indexOf('项目团队') != -1){
                 this.isShowDeliBtnList = false
                 this.isShowSponsor = false
               }
            }
            this.isCheckOut = res.data.isCheckOut
          } else {
            this.deliverableName = ''
            this.$message.error('操作错误')
          }
        } else {
          this.$message.error('接口失败！')
        }
      })
      //基本信息
      getAttributeGroup({oid: this.currentOid}).then((res) => {
        if (res && res.status === 200) {
          if (res.data && res.data.success) {
            if (res.data.data.length > 0) {
         //    console.log(res.data.data[0].rows)
              this.basicInformation = res.data.data[0].rows
            } else {
              this.basicInformation = []
            }
          } else {
            this.basicInformation = []
            this.$message.error(res.data.message)
          }
        } else {
          this.$message.error('接口失败！')
        }
      })
      //历史版本
      getVersionHistory({oid: this.currentOid}).then((res) => {
        if (res && res.status === 200) {
          if (res.data && res.data.success) {
          //  console.log(res.data)
            this.historyRecord = res.data.data
            this.historyTableKey = 'oid'
          } else {
            this.historyRecord = []
            this.$message.error(res.data.message)
          }
        } else {
          this.$message.error('接口失败！')
        }
      })
      // 获取交付物流程节点（流程指引）
      getProcessSteps({oid: this.currentOid}).then((res) => {
        if (res && res.status === 200) {
          if (res.data.success) {
            if (res.data && res.data.data && res.data.data !== '' && res.data.data.length > 0) {
              res.data.data.map((item) => {
                item.state = item.state.toLowerCase(); // 统一转化成小写
              });
             let arr = res.data.data.filter((e)=>{
                return e.userFullName !=='';
              })
              this.stepArr = arr
              //是否显示“起草人..”按钮
              let runStep = res.data.data[res.data.data.length - 1]//结束节点的前一个节点      
              if (res.data.data[0].userFullName === this.userinfo.realName && runStep && this.fileSingleItem.state!=='已发放C' &&
                (runStep.state === '' && this.$route.query.isShow || runStep.state.indexOf('running') > -1) && 
                this.deliverableName.indexOf('项目团队') == -1) {
                this.isShowSponsor = true
              } else {
                this.isShowSponsor = false
              }
              //处于流程中，状况!=已完成，流程视图有数据，显示交付物添加、移除按钮
              if (this.currentOid.indexOf('WorkItem') > -1) {
                if (this.fileSingleItem.workItemState !== '已完成' && (this.fileSingleItem.state === '正在工作' || this.fileSingleItem.state === '重新工作') &&
                this.deliverableName.indexOf('项目团队') == -1) {
                  this.isShowDeliBtnList = true
                } else {
                  this.isShowDeliBtnList = false
                }
              } else {
                this.isShowDeliBtnList = false
              }
            } else {
              this.isShowSponsor = false
              this.stepArr = []
            }
          } else {
            this.stepArr = []
            this.$message.error(res.data.message)
          }
        } else {
          this.$message.error('接口失败！')
        }
      })
      // 获取交付物流程记录
      getDisposeStatus({oid: this.currentOid}).then((res) => {
      //  console.log(res)
        if (res && res.status === 200) {
          if (res.data && res.data.success == 'true') {
            if (res.data.data.length > 0) {
              // this.tableArr = res.data.data
              this.tableArr = _.orderBy(res.data.data, ['workCompletedDate'], ['desc'])//按照创建时间降序排序
               this.tableArr.splice(0, 0, this.tableArr[this.tableArr.length - 1])      //把最后一个元素复制到首个
              this.tableArr.splice(-1, 1);       //删除最后一个元素
              // this.tableArr.splice(-1, 1)        //删除最后一个提交人是空的
              // console.log(this.tableArr)
            } else {
              this.tableArr = []
            }
          } else {
            this.tableArr = []
            this.$message.error(res.data.message)
          }
        } else {
          this.$message.error('接口失败！')
        }
      })
      this.getDeliverables()//交付物列表
    },
    
    /**
     * getRoutingIndex 获取流程操作
     */
    getRoutingIndex() {
      getRouting({oid: this.currentOid}).then((res) => {
        if (res && res.status === 200) {
          if (res.data && res.data.success) {
            if (res.data.data && res.data.data.length > 0) {
              this.radioArr = res.data.data
            } else {
              this.radioArr = []
            }
          } else {
            this.radioArr = []
            this.$message.error(res.data.message)
          }
        } else {
          this.$message.error('接口失败！')
        }
      })
    },
    /**
     * getDeliverables 获取交付物列表
     */
    getDeliverables() {
      getDocProcessReviewObjs({oid: this.currentOid}).then((res) => {
        this.loadVisible = false
        if (res && res.data.success) {
          if (res.data.data && res.data.data.length > 0) {
            this.tableDataDe = res.data.data
            this.deliverTableKey = 'oid'
          } else {
            this.tableDataDe = []
          }
        } else {
          this.tableDataDe = []
          this.$message.error(res.data.message)
        }
      })
    },
    //交付物预览
    routerSubmitDel(val) {
      window.open(val['deliverable.name.url'])
    },
    /**
     * comm-modal 组件回调
     * 功能：通知更新数据
     */
    initSigoView() {
      if (this.recordingKey === 'commElDelete') {
        return
      }
      let sessionOid = JSON.parse(sessionStorage.getItem('fileSingleTableItem')); 
      let newOid = sessionOid.oid==undefined?'':sessionOid.oid;
      this.currentOid = newOid||this.currentOid;
      this.initData()
      // this.$router.push({path: "fileSingle"})
    },
    /**
     * addDeliver 添加交付物 调用公共组件中comm-el-updata
     */
    addDeliver() {
      this.isShowUploadFile = true
      // this.$refs.commElFilestartUpload.openModal(true)
    },
    //关闭弹框
    closeUpFile() {
      this.isShowUploadFile = false
    },
    /**
     * comm-el-filestart-upload 组件回调
     * 功能，通知更新交付物列表
     */
    initTableDataDeliver() {
      this.getDeliverables()
    },
    callbackData(datas) {
      // console.log('选择的数据---',data)
      //判断是否有相同数据
      let newData = lodash.concat(this.tableDataDe, datas)
      let newDataOids = newData.map((item) => {
        return item.oid
      })
      let newDataState = newData.map((item) => {
        return item.state
      })
      if (newDataState.toString().indexOf('审阅') > -1 || newDataState.toString().indexOf('发放') > -1 || newDataState.toString().indexOf('作废') > -1) {
        this.$message.error('请添加正在工作/重新工作的文档！');
        return
      }
      // console.log('oids---',newDataOids)
      if (new Set(newDataOids).size !== newDataOids.length) {
        this.$message.error('交付物不能重复添加！');
        return
      } else {
        let arr = JSON.stringify(this.cycleID(datas))
        // this.getDeliverable(newData)
        // this.getDeliverables()
        addDocProcessReviewObj({oid: this.currentOid, reviewObjOids: arr}).then((res) => {
          if (res && res.data.success) {
            this.$message.success('添加成功......');
            this.getDeliverables()
          } else {
            this.$message.error(res.data.message)
          }
        })
        this.isShowUploadFile = false
      }
    },
    /**
     * taskTable 组件回调方法
     * 功能： 复选框选中
     */
    selectRowsEvent(val) {
      // console.log('选中的数据', val)
      this.selectRowsDeliver = val
    },
    /**
     * delDeliver 移除交付物
     */
    delDeliver() {
      let _this = this
      if (this.selectRowsDeliver.length < 1) {
        this.$message.error('请选择您所需要删除的交付物')
        return
      }
      let arr = []
      this.selectRowsDeliver.forEach(item => {
        arr.push(item.oid)
      })
      this.$confirm({
        title: '是否确定移除该交付物？',
        content: '',
        okText: '是',
        okType: 'danger',
        cancelText: '否',
        onOk() {
          removeDocProcessReviewObj({
            oid: _this.currentOid,
            reviewObjOids: JSON.stringify(arr)
          }).then((res) => {
            if (res && res.data.success) {
              _this.tableSelectArr = []
              _this.selectRowsDeliver = []
              _this.getDeliverables()
              _this.$message.success('删除成功......');
            } else {
              _this.$message.error(res.data.message)
            }
          })
        }
      });
    },
    /**
     * commonProcessSettings 组件回调方法
     * 功能： 提交审核人
     */
    fields(val) {
      let datas = {oid: '', processUsers: JSON.stringify(val)}
      // this.fileSingleDataItem.tableArr.forEach(item => {
      //   data.oids.push(item.oid + '')
      // })
      datas.oid = this.fileSingleItem.oid
      updateTeamPrincipal(datas).then((res) => {
        if (res && res.status == 200) {
          if (res.data.success) {
            this.$message.success('提交成功');
            //提交审核操作
            if (this.radioVal === 'TRANSFER') {
              this.onCompleteWorkItemDivTransfer(this.radioVal, this.desVal, this.reassignUser)
            } else {
              this.onCompleteWorkItemDiv(this.radioVal, this.desVal)
            }
          } else {
            this.$message.error(res.data.message)
          }
        } else {
          this.$message.error('接口失败！')
        }
      })
    },
    /**
     * commonProcessSettings 组件回调方法
     * 功能： 提交审核人
     */
    submitProcessPeople(radioVal, desVal, userId) {
      this.radioVal = radioVal
      this.desVal = desVal
      this.reassignUser = userId
    //  console.log(radioVal,desVal,userId)
      if (this.isShowProcessSetting) {
        this.$refs.commonProcessSettings.handleChange()
      } else {
        if (radioVal === 'TRANSFER') {
          this.onCompleteWorkItemDivTransfer(this.radioVal, this.desVal, this.reassignUser)
        } else {
          this.onCompleteWorkItemDiv(this.radioVal, this.desVal)
        }
      }
    },
    /**
     * 功能：提交流程操作
     */
    onCompleteWorkItemDiv(radioVal, desVal) {
      radioVal = this.radioVal
      desVal = this.desVal
      let parms = {}
      if (this.radioArr.length > 0) {
        parms = {
          oid: this.currentOid,
          routeChoice: radioVal,
          comment: desVal,
          custActVar: '',
          reassignUser: ''
        }
      } else {
        parms = {
          oid: this.currentOid,
          routeChoice: '',
          comment: desVal,
          custActVar: '',
          reassignUser: ''
        }
      }
      if (this.radioArr.length > 0 && radioVal == '') {
        this.$message.error('请选择操作！');
        return
      }
      if (desVal == '') {
        this.$message.error('请输入处理意见！');
        return
      }
      completeWorkItem(parms).then((res) => {
        if (res && res.status === 200) {
          if (res.data && res.data.success) {
            this.$message.success('流程操作成功！')
            //跳转至待办页面，并关闭查看交付物页面
            let tabArrNew = JSON.parse(sessionStorage.getItem('tabArr'))
            tabArrNew = tabArrNew.filter((rec) => {
              return rec.title !== '查看交付物'
            })
            this.$store.commit('SET_TABS', tabArrNew)
            this.$router.push('/toDoPage');
          } else {
            this.$message.error(res.data.message)
          }
        } else {
          this.$message.error('接口失败！')
        }
      })
    },
    /**
     * 功能：提交流程操作--转办
     */
    onCompleteWorkItemDivTransfer(radioVal, desVal, reassignUser) {
      radioVal = this.radioVal
      desVal = this.desVal
      reassignUser = this.reassignUser
      let parms = {}
      if (this.radioArr.length > 0) {
        parms = {
          oid: this.currentOid,
          routeChoice: radioVal,
          comment: desVal,
          custActVar: '',
          reassignUser: reassignUser
        }
      } else {
        parms = {
          oid: this.currentOid,
          routeChoice: '',
          comment: desVal,
          custActVar: '',
          reassignUser: reassignUser
        }
      }
      if (this.radioArr.length > 0 && radioVal == '') {
        this.$message.error('请选择操作！');
        return
      }
      if (this.radioVal === 'TRANSFER' && this.reassignUser == '') {
        this.$message.error('请选择转办人员！');
        return
      }
      if (desVal == '') {
        this.$message.error('请输入处理意见！');
        return
      }
      reassignWorkItem(parms).then((res) => {
        if (res && res.status === 200) {
          if (res.data && res.data.success) {
            this.$message.success('流程操作成功！')
            //跳转至待办页面，并关闭查看交付物页面
            let tabArrNew = JSON.parse(sessionStorage.getItem('tabArr'))
            tabArrNew = tabArrNew.filter((rec) => {
              return rec.title !== '查看交付物'
            })
            this.$store.commit('SET_TABS', tabArrNew)
            this.$router.push('/toDoPage');
          } else {
            this.$message.error(res.data.message)
          }
        } else {
          this.$message.error('接口失败！')
        }
      })
    },
    /**
     * commElProcessHandle 组件回调方法
     * 功能： 打开抽屉
     */
    openDraw() {
      this.isShowProcessHandle = true
    },
    /**
     * commElProcessHandle 组件回调方法
     * 功能： 关闭抽屉
     */
    closeDraw() {
      this.isShowProcessHandle = false
    },
    /**
     *获取流程人
     */
    getProcess() {
      getWFSelectPrincipal({
        oid: this.fileSingleItem.oid,
      }).then((res) => {
        if (res && res.data.success) {
          //每个下拉菜单的值
          let optionUser = []
          optionUser = res.data.data[0].selectedUsers
          res.data.data.forEach((item, index) => {
            if (index === 0) return
            //下拉框默认显示的值
            let initUser = []
            initUser = item.initUsers.map((rec) => {
              return rec.fullname
            })
            this.formData.push({
              name: item.name,
              oid: item.oid,
              required: item.required,
              selsectData: optionUser,
              checkSelsectData: initUser
            })
          })
        } else {
          this.$message.error(res.data.message)
        }
      })
    },
  },
};
</script>
<style lang="less" scoped>
.examineProject{
   height: calc(100vh - 173px);
    background-color: #f0f2f5;
    // background: #fff;
    // padding: 16px;
    overflow-y: scroll;
    overflow-x: hidden;
}
.main {
  background-color: #f0f2f5;
}
.headMain {
  padding: 20px 20px 0 20px;
  box-sizing: border-box;
  background-color: #fff;
}
.headTitle {
  display: flex;
  & > p {
    font-size: 20px;
    color: rgba(0, 0, 0, 0.85);
    line-height: 28px;
    font-weight: 500;
  }
}
.productTitle {
  margin: 10px 0;
  font-size: 16px;
  color: rgba(0, 0, 0, 0.85);
  font-weight: 500;
  box-sizing: border-box;
}
.basicInformation {
  padding-bottom: 62px;
  display: flex;
  flex-wrap: wrap;
  box-sizing: border-box;
  & > li {
    margin-bottom: 16px;
    width: 33.3%;
    flex-grow: 1;
    & > span:nth-child(1) {
      font-size: 14px;
      color: #666666;
    }
    & > span:nth-child(2) {
      font-size: 14px;
      color: #333333;
    }
    .activeSpan {
      cursor: pointer;
      color: #386bd7 !important;
    }
  }
}
.moreBtnList {
  left: 0px;
}
.style-pac-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #dcdcdc;
  box-sizing: border-box;
  .title {
    border-bottom: none;
  }
}
/deep/ .ant-dropdown-open {
  .anticon {
    border-left: none;
  }
}
.style-dropdown-menu {
  width: 140px;
  background: #FFFFFF;
  box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.20);
  border-radius: 4px;
  box-sizing: border-box;
  & > .ant-dropdown-menu-item {
    cursor: pointer;
    padding-left: 0px;
    font-size: 14px;
    color: #666666;
    height: 32px;
    box-sizing: border-box;
    /*&:hover {
      color: #386BD7;
      background-color: #E8F0FD;
    }*/
  }
  .menuBtn {
    width: 140px;
    border: 0px;
    background-color: transparent;
    line-height: 20px;
    text-align: left;
    padding-left: 24px;
  }
  .menuBtn:hover {
    color: #386BD7;
    background-color: #E8F0FD;
  }
}
  .styleTabs > li{
    margin: 0;
    width: 95px;
    font-size: 16px;
  }
  .styleTabs > li:hover{
    color: #386BD7 !important;
    border-bottom: 2px solid #386BD7 !important;
    transition: border 0.5s;
  }
.style-button {
  margin-right: 23px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 80px;
  padding: 0 10px;
}
.previewBtn {
  width: 88px;
  height: 32px;
  margin-left: 20px;
  font-size: 16px;
  background-color: #386BD7;
  border-radius: 4px;
  color: #FFFFFF;
  display: flex;
  justify-content: center;
  align-items: center;
}
.previewBtn:hover {
  cursor: pointer;
}
.processName {
  height: 40px;
  font-size: 20px;
  font-weight: 550;
  color: rgba(0, 0, 0, 0.85);
}
.basicInfoName {
  width: 20vw;
  position: relative;
  float: left;
  word-wrap: break-word;
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.messageContent {
  width: 100%;
  margin-bottom: 10px;
  display: flex;
  .message_de {
    width: 30%;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    .messageList {
      min-width: 25%;
      margin: 5px 0;
      font-size: 14px;
      text-align: right;
      display: flex;
      justify-content: flex-start;
    }
  }
  .message_deOne {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    .messageList {
      min-width: 25%;
      margin: 5px 0;
      font-size: 14px;
      text-align: right;
      display: flex;
      justify-content: flex-start;
    }
  }
}
.operatingBtnList {
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 22px;
  height: 56px;
  background: #FFFFFF;
  //box-shadow: 2px 0px 4px 0px rgba(0,0,0,0.2);
  border-radius: 1px;
  box-sizing: border-box;
  .ant-btn {
    margin: 0 5px;
    width: 72px;
    height: 32px;
  }
}
</style>